home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / UI & Events / Overview of UI Events Recipes < prev    next >
Encoding:
Text File  |  1995-11-07  |  2.5 KB  |  75 lines  |  [TEXT/ttxt]

  1. OpenDoc™ Recipes
  2.  
  3. UI Events Recipe Overview
  4. By The OpenDoc Design Team
  5. November, 1995
  6.  
  7.  
  8. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  9. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  10. Mac and OpenDoc are trademarks of Apple Computer, Inc. 
  11.  
  12.  
  13. Introduction
  14.  
  15. The UI Events subsystem of OpenDoc is responsible for window and menu management and the distribution of events to parts. 
  16.  
  17. List of Recipes
  18.  
  19. Opening and Closing Windows
  20. Opening a Part into a Window
  21. Activation
  22. Dialogs
  23. Shared Utility Windows
  24. Basic Event Handling
  25. Mouse Events
  26. Window Events
  27. Menus
  28. Implementing  a Dispatch Module
  29. Implementing a Focus Module
  30.  
  31. Many of these recipes are virtually identical to their DR3 counterparts. New information has generally been labelled New in DR4, and the source code has been updated in some cases.
  32.  
  33. Source Code Examples
  34.  
  35. The code snippets in these recipes are mostly taken from the Test Clock part, source code for which is included with these recipes. Error checking is noticeably absent.  The test clock is not included in binary form, though the fine ODFClock is.
  36.  
  37. It's a good idea to look at the official sample part editors as well.   
  38.  
  39. Structure of Clock Part
  40.  
  41. The Clock part is implemented with several C++ classes.  The System Object Model™ (SOM) class representing the part has a single instance variable which is a C++ object containing all the part instance data as well as methods to delegate to.  A C++ object  is also attached to each frame's part info, and some methods of the SOM class delegate to that object.  
  42.  
  43. For example, the HandleEvent looks as follows:
  44.  
  45. SOM_Scope ODBoolean  SOMLINK AppleTestClock_ClockHandleEvent(AppleTestClock_Clock *somSelf, Environment *ev,
  46.                          ODEventData* event,
  47.                             ODFrame* frame,
  48.                             ODFacet* facet )
  49. {
  50.     AppleTestClock_ClockData *somThis = AppleTestClock_ClockGetData(somSelf);
  51.     AppleTestClock_ClockMethodDebug("Clock","HandleEvent");
  52.  
  53.     ODBoolean wasHandled = kODFalse;
  54.     ClockFrame* clockFrame = (ClockFrame*) frame->GetPartInfo(ev);
  55.     switch ( event -> what ) 
  56.     {        
  57.         …    
  58.         case kODEvtNull:
  59.             if (clockFrame)
  60.                 clockFrame->Idle(ev, event);
  61.             else
  62.                 _fClockPart->Idle(ev, event);
  63.             wasHandled = kODTrue;
  64.             break;
  65.         case kODEvtKeyDown:
  66.             wasHandled = clockFrame->HandleKeyDown(ev, event);
  67.             break;
  68.         …
  69.     }
  70.     return wasHandled;
  71. }
  72.  
  73. The Clock part has several subclasses of ClockFrame representing the main content (time) view and a variety of dialogs.
  74. These frame objects are attached to the part info in DisplayFrameAdded() and DisplayFrameConnected(). 
  75.